Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nice_things/text/escape_single_quotes.sh

escape_single_quotes

Since 0.3.0 · Source

import "{ escape_single_quotes }" from nice_things/text/escape_single_quotes.sh

Synopsis
escape_single_quotes [<text>]

Configuration

Description
Escape <text> for use in a shell script single-quoted string, and print the result. If the <text> parameter is omitted, text will be read from stdin.

Internally, this function uses the substitute_characters function. All occurrences of ' are substituted with '"'"'.

This function exists mostly for streaming use-cases. If you want to quote some text to make it safe to eval, consider using the quote function instead.

Options

Operands
<text>: The text to operate on. If omitted, stdin will be used.

Stdin
The text will be read from stdin if the <text> parameter is omitted.

Stdout
The result will be printed to stdout.

Stderr

Exit status
0: Successful completion.

Abort

Usage examples

escape_single_quotes </path/to/file